function stripHtmlTags(s,max){
s=s.replace(/<br.*?>/ig, ' ');
return s.replace(/<.*?>/ig, '').split(/\s+/).slice(0,max-1).join(' ')
}

function mygallery(json) {
	img  = new Array();
  	for (var i = 0; i < g_numposts; i++) {
    	  var entry = json.feed.entry[i];
          var posttitle = entry.title.$t;
    	  var posturl;

    	if (i == json.feed.entry.length) break;
    	for (var k = 0; k < entry.link.length; k++) {
      		if (entry.link[k].rel == 'alternate') {
        		posturl = entry.link[k].href;
        		break;
      		}
    	}
                      
    	if ("content" in entry) {var postcontent = entry.content.$t;}
    	else
    	if ("summary" in entry) {var postcontent = entry.summary.$t;}
    	else  postcontent = "";
	s = postcontent; a = s.indexOf("<img"); b = s.indexOf("src=\"",a); c = s.indexOf("\"",b+5); d = s.substr(b+5,c-b-5);
	
	if((a!=-1)&&(b!=-1)&&(c!=-1)&&(d!="")) {img[i] = d;} 
        else {img[i]="http://1.bp.blogspot.com/_u4gySN2ZgqE/SosvnavWq0I/AAAAAAAAArk/yL95WlyTqr0/s400/noimage.png";}

	var list_mygallery = '<li><div class="mytext"><a href="'+posturl+'"><img class="sidim" src="'+img[i]+'" /></a><div class="clear"></div><h2><a href="'+posturl+'">'+posttitle+'</a></h2><p>'+stripHtmlTags(postcontent,g_numcontents)+' ... </p></div></li>';

	document.write(list_mygallery);   
	}
	 
}

if (mode=="all") {
document.write("<script type=\"text/javascript\" src=\""+homepage+"/feeds/posts/default?max-results="+g_numposts+"&alt=json-in-script&callback=mygallery\"><\/script>"); }
if (mode=="single") {
document.write("<script type=\"text/javascript\" src=\""+homepage+"/feeds/posts/default/-/"+g_label+"?max-results="+g_numposts+"&alt=json-in-script&callback=mygallery\"><\/script>"); }
